<?php

/******************************************************************************
 *
 *	PROJECT: Flynax Classifieds Software
 *	VERSION: 4.0.1
 *	LISENSE: FL87MPRYOA0R - http://www.flynax.com/license-agreement.html
 *	PRODUCT: Auto Classifieds
 *	DOMAIN: www.siyaradiali.com
 *	FILE: JSONRESPONSE.PHP
 *
 *	This script is a commercial software and any kind of using it must be 
 *	coordinate with Flynax Owners Team and be agree to Flynax License Agreement
 *
 *	This block may not be removed from this file or any other files with out 
 *	permission of Flynax respective owners.
 *
 *	Copyrights Flynax Classifieds Software | 2012
 *	http://www.flynax.com/
 *
 ******************************************************************************/

/* system config */
require_once( '../../includes/config.inc.php' );
require_once( RL_ADMIN_CONTROL . 'ext_header.inc.php' );

/* load system lib */
require_once( RL_LIBS . 'system.lib.php' );

switch ($_GET['q']){
	case 'phrase':
		$key = $_GET['key'];
		$lang = $_GET['lang'];
	
		$output = $rlDb -> getOne('Value', "`Key` = '{$key}' AND `Code` = '{$lang}'", 'lang_keys');
		break;
		
	case 'accounts':
		$str = $_GET['str'];
		$fields = $_GET['add_id'] ? ', `ID`' : '';

		$sql = "SELECT `Username` {$fields} FROM `" . RL_DBPREFIX . "accounts` WHERE `Username` REGEXP '^".$str."' AND `Status` ='active'";
		$output = $rlDb -> getAll($sql);
		break;
		
	default:
		exit;
		break;
}

$rlHook -> load('apPhpJsonResponse');

$reefless -> loadClass( 'Json' );
echo $rlJson -> encode( $output );